//
//  GridViewController.m
//  ipad_split
//
//  Created by protocal 100TV on 12-10-8.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "GridViewController.h"
#import "YKBrandsCell.h"
#import "YKXIBHelper.h"

@interface GridViewController ()

@end

@implementation GridViewController
@synthesize gridview;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [self setGridview:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
	return YES;
}

- (void)dealloc {
    [gridview release];
    [super dealloc];
}

#pragma mark-
-(unsigned int) numOfGridViewItem:(YKBrandsGridView*) agridView
{
    return 20;
}
-(CGSize) sizeOfGridViewItem:(YKBrandsGridView*) agridView
{
    return CGSizeMake(168, 293);
}
-(YKBrandsGridViewCell*) gridView:(YKBrandsGridView*) agridView cellForIndex:(unsigned int) aindex
{
    static NSString * identifier = @"cell";
    YKBrandsCell  * cell = (YKBrandsCell*)[agridView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = (YKBrandsCell*)[YKXIBHelper loadObjectFromXIBName:@"YKBrandsCell" type:[YKBrandsCell class]];
    }
    [cell.optimage setImage:[UIImage imageNamed:@"a.png"]];
    cell.labelDD.text = [[[NSString alloc] initWithFormat:@"第%d个", aindex] autorelease];
    cell.tag=aindex;
    return cell;
}
-(void) gridView:(YKBrandsGridView*) agridView didSelectCell:(YKBrandsGridViewCell*) acell atIndex:(unsigned int) aindex
{
    NSLog(@"dada:%d", aindex);
}

@end
















